import { MutationTree } from "vuex";
import { State } from "./state";

//! 使用常量替代 Mutation 事件类型
export enum Mutation {
  UPDATEAUTHOR = "UPDATEAUTHOR",
}

// 声明Mutaions的类型
//内部载荷 (state, payload)
export type Mutations<S = State> = {
  [Mutation.UPDATEAUTHOR](state: S, payload: string): void;
};

//实例化这个mutations
//MutationTree也是用于明确content的键对象
export const mutations: MutationTree<State> & Mutations = {
  [Mutation.UPDATEAUTHOR](state: State, payload: string = "ASITER") {
    state.name = payload;
  },
};
